/*
************************************************************
Object.clone
by  : Steve Kamerman (kamermans at teratechnologies.net)
Blog: http://www.teratechnologies.net/stevekamerman
Ver : 1.0
Date: 13Jan2007
************************************************************
Object.clone creates a perfect copy of an object
Modified from R.Arul Kumaran's version to support Date Objects
*/

Object.prototype.clone = function() {
  if (this instanceof Array) {
    var to = [];
    for (var i = 0; i<this.length; i++) {
      to[ i] = (typeof (this[ i]) == "object") ? this[ i].clone() : this[ i];
    }
  }else if(this instanceof Date){
    var to = new Date(this.getTime());
  }else if (this instanceof XML || this instanceof MovieClip) {
  // can't clone this so return null
  var to = null;
  trace("Object.clone won't work on MovieClip or XML");
  } else {
    var to = {};
    for (var i in this) {
      to[ i] = (typeof (this[i ]) == "object") ? this[ i].clone() : this[ i];
    }
  }
  return(to);
}
ASSetPropFlags(Object.prototype, ["clone"], 1);
/*
Usage:-
var date1 = new Date(2007,0,1); // January 1, 2007 00:00:00
var date2 = date1.clone();
var date2.setMonth(1);

// now date2 contains the Date Object for Febuary 1, 2007 00:00:00
// changing date2 will not affect date1
*/